package com.mapper;

import com.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ProductMapper {

    @Select("SELECT * FROM product")
    List<Product> findAll();

    @Select("SELECT * FROM product WHERE name LIKE CONCAT('%', #{keyword}, '%')")
    List<Product> search(String keyword);

    @Select("SELECT * FROM product WHERE category_id = #{categoryId}")
    List<Product> findByCategoryId(Long categoryId);
@Select("SELECT * FROM product WHERE id = #{productId}")
    Product finById(Long productId);
}